package com.lhy.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Liu Hangyu
 * @date 2022/1/6 21:05
 */
@CrossOrigin
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private  HttpServletRequest request;

    @GetMapping("selectAll")
    public String selectAll( String username) {
        //直接获取token
//        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
        String token = request.getHeader("token");// 从 http 请求头中取出 token
        System.out.println("------------"+token);
        System.out.println("user服务中selectAll被调用");
        return "查询所有" + username;
    }

}
